//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package objects;

import common.GlobalID;
import init.StaticData;

import java.awt.geom.Path2D.Float;

public class ForestsInstanceEntry {
  private final Integer objectId;
  private final Integer x;
  private final Integer y;
  private final Integer instance;
  private final Integer width;
  private final Integer height;
  private final Integer toolId;

  public ForestsInstanceEntry(Integer id, Integer x, Integer y, Integer instance) {
    this.objectId = id;
    this.x = x;
    this.y = y;
    this.instance = instance;
    ForestsEntry fe = Forests.getById(this.objectId);
    this.width = fe.getTileWidth();
    this.height = fe.getTileHeight();
    this.toolId = StaticData.getGlobalId(fe.getTool());
  }

  public int getInstanceId() {
    return GlobalID.create(5, this.instance.intValue());
  }

  public int getObjectId() {
    return this.objectId.intValue();
  }

  public int getX() {
    return this.x.intValue();
  }

  public int getY() {
    return this.y.intValue();
  }

  public int getWidth() {
    return this.width.intValue();
  }

  public int getHeight() {
    return this.height.intValue();
  }

  public Integer getToolId() {
    return this.toolId;
  }

  public boolean isPointInside(int px, int py) {
    return px < this.x.intValue() + this.width.intValue() && px >= this.x.intValue() && py < this.y.intValue() + this.height.intValue() && py >= this.y.intValue();
  }

  public boolean isEntryInsidePath(Float p) {
    return this.width.intValue() > 1 && this.height.intValue() > 1?p.contains(this.getPath().getBounds2D()):p.contains((double)this.x.intValue(), (double)this.y.intValue());
  }

  public Float getPath() {
    Float path = new Float();
    path.moveTo((float)this.x.intValue(), (float)this.y.intValue());
    path.lineTo((float)(this.x.intValue() + this.width.intValue()), (float)this.y.intValue());
    path.lineTo((float)(this.x.intValue() + this.width.intValue()), (float)(this.y.intValue() + this.height.intValue()));
    path.lineTo((float)this.x.intValue(), (float)(this.y.intValue() + this.height.intValue()));
    path.closePath();
    return path;
  }

  public Float getPath(int scale) {
    Float path = new Float();
    path.moveTo((float)(this.x.intValue() * scale), (float)(this.y.intValue() * scale));
    path.lineTo((float)(this.x.intValue() * scale + this.width.intValue() * scale), (float)(this.y.intValue() * scale));
    path.lineTo((float)(this.x.intValue() * scale + this.width.intValue() * scale), (float)(this.y.intValue() * scale + this.height.intValue() * scale));
    path.lineTo((float)(this.x.intValue() * scale), (float)(this.y.intValue() * scale + this.height.intValue() * scale));
    path.closePath();
    return path;
  }
}
